import { Dialog } from 'vant';
import Vue from 'vue';
Vue.use(Dialog);
export const swipeCell = {
	methods:{
		goPush(fromId,num){
			this.$router.push({
				path:'/approvalDetails',
				query:{					
					'fromId':fromId,
					'num':num
				}
			})
		},			
		beforeClose({ position, instance }) {
		      switch (position) {
		        case 'left':
		        case 'cell':
		        case 'outside':
		          instance.close();
		          break;
		        case 'right':
		          this.instance = instance
		          break;
		    }
		},			
		delet(form_id,num){
			Dialog.confirm({
			  message: '确定删除吗？',
			}).then(() => {
				this.instance.close()
			    this.$axios.post(`/api/delete?_form=${form_id}&_num=${num}`).then(res => {
			    	if (res.data.code === 0) {
			    		this.$toast('删除成功')
			    		this.fromDataList.splice(this.fromDataList.findIndex(e => e.num === num), 1)
			    	} else {
			    		this.$toast('删除失败')
			    	}
			    })				
			}).catch(() => {});
		},
		edit(form_id,num,title,type){
			this.$router.push({
				path:'/details',
				query:{
					form_id,
					num,
					title,
					type
				}
			})
		},
	}	
} 